package com.sc.nft.dao;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.BoxTakeConversionCondition;
import com.sc.nft.entity.vo.QueryBoxConditionVO;
import com.sc.nft.mapper.BoxTakeConversionConditionMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 盲盒兑换条件(BoxTakeConversionCondition)表Dao层
 *
 * @author 王伟成
 * @since 2023-11-07 16:54:54
 */
@Slf4j
@Repository
public class BoxTakeConversionConditionDao extends ServiceImpl<BoxTakeConversionConditionMapper, BoxTakeConversionCondition> {

    public void removeByProductBoxId(Long boxId) {
        log.info("根据盲盒商品id删除盲盒兑换条件,productBoxId:{}", boxId);
        this.lambdaUpdate().eq(BoxTakeConversionCondition::getBoxId, boxId).remove();
    }
    public List<QueryBoxConditionVO> queryBoxCondition(Long boxId) {
        // 直接使用Wrapper创建查询
        return BeanUtil.copyToList(lambdaQuery().eq(BoxTakeConversionCondition::getBoxId,boxId).list(), QueryBoxConditionVO.class);
    }
}
